package br.sed.theenemy.presentation.action.json.exception;

/**
 * This Exception and its subclasses should be thrown to report errors that the
 * front-end application is prepared to receive. For instance: invalid parameters,
 * non-logged user, etc.
 * 
 * @author JulioCB
 * @email jcbjulio@gmail.com
 */
public class ExpectedException extends Exception {

	private static final long serialVersionUID = -8738648679908312961L;
	
	private String[] errors;
    private Object content;
    
    /**
     * Constructs a new exception with the specified error id.
     * 
     * @param errorIds String array with the error ids.
     * @param content Content of the Json response attribute. 
     */        
    public ExpectedException(final String[] errorIds, final Object content) {
        this.errors = (String[]) errorIds.clone();
        this.content = content;
    }
    
    /**
     * Constructs a new exception with the specified error id.
     * 
     * @param errorId String with the error id.
     */
    public ExpectedException(final String error) {
        this(error, null);
    }
    
    /**
     * Constructs a new exception with the specified error id.
     * 
     * @param errorId String with the error id.
     * @param content Content of the Json response attribute. 
     */    
    public ExpectedException(final String error, final Object content) {
        this(new String[] { error }, content);
    }

    /**
     * Constructs a new exception with the specified error ids.
     * 
     * @param errorIds String array with the error ids.
     */
    public ExpectedException(final String[] errors) {
        this(errors, null);
    }
    
    /**
     * Returns exception content.
     * 
     * @return Exception content. 
     */
    public Object getContent() {
        return content;
    }
    
    /**
     * Returns array that contains the error ids.
     * 
     * @return Array that contains the error ids
     */
    public String[] getErrorIds() {
        return errors;
    }
}
